home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / SpriteWorld 2.2 / SpriteWorld Examples / Shark Attack / Sources & Headers / MyUtils.c < prev    next >
Encoding:
Text File  |  1997-09-12  |  1.3 KB  |  39 lines  |  [TEXT/CWIE]

  1. ///--------------------------------------------------------------------------------------
  2. // MyUtils.c
  3. ///--------------------------------------------------------------------------------------
  4.  
  5. #include "MyUtils.h"
  6.  
  7.  
  8. ///--------------------------------------------------------------------------------------
  9. //  FillBackgroundWithPict - fills background with pict, aligning to bottom of screen
  10. ///--------------------------------------------------------------------------------------
  11.  
  12. void    FillBackgroundWithPict(SpriteWorldPtr spriteWorldP, PicHandle thePictH)
  13. {
  14.     Rect    pictRect, oldPictRect, backRect;
  15.     short    pictOffset;
  16.     
  17.     SWSetPortToBackground(spriteWorldP);
  18.     pictRect = (**thePictH).picFrame;
  19.     backRect = spriteWorldP->backRect;
  20.     
  21.         // Align the picture to the bottom of the screen, not the top, so the rocks
  22.         // always appear, regardless of the screen size
  23.     pictOffset = backRect.bottom - pictRect.bottom;
  24.     OffsetRect(&pictRect, 0, pictOffset);
  25.     DrawPicture(thePictH, &pictRect);
  26.     
  27.         // Use the SpriteWorld's offscreenDrawProc to fill the rest of the background
  28.     while (pictRect.right < backRect.right)
  29.     {
  30.         oldPictRect = pictRect;
  31.         OffsetRect(&pictRect, pictRect.right - pictRect.left, 0);
  32.         
  33.         (*spriteWorldP->offscreenDrawProc)(spriteWorldP->backFrameP,
  34.                 spriteWorldP->backFrameP, &oldPictRect, &pictRect);
  35.     }
  36. }
  37.  
  38.  
  39.